<template>
  <div class="dashboard-container">
    <div class="dashboard-text">用户名: {{ username }}</div>
    <el-card style="margin: 10px">
      <div class="digitCard">
        <i class="el-icon-user"></i>
        <p>用户人数{{ digitData.userNumber }}</p>
      </div>
    </el-card>
    <el-card style="margin: 10px">
      <div class="digitCard">
        <i class="el-icon-user"></i>
        <p>在线律师{{ digitData.lawyerNumber }}</p>
      </div>
    </el-card>
    <el-card style="margin: 10px">
      <div class="digitCard">
        <i class="el-icon-user"></i>
        <p>总计案件{{ digitData.caseNumber }}</p>
      </div>
    </el-card>
    <el-card style="margin: 10px">
      <div class="digitCard">
        <i class="el-icon-user"></i>
        <p>招聘职位数量{{ digitData.recruitmentNumber }}</p>
      </div>
    </el-card>
  </div>
</template>

<script>
import {mapGetters} from 'vuex'
import {getDashboardData} from "@/api/dashboard";

export default {
  name: 'Dashboard',
  computed: {
    ...mapGetters([
      'username'
    ])
  },
  data() {
    return {
      digitData: {}
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      getDashboardData().then(res => {
        this.digitData = res.data.number
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }

  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}

.digitCard {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  font-size: 22px;

  i {
    color: #20a0ff;
  }

  p {
    margin: 0 10px;
  }
}
</style>
